let isCorrent = require('../Component/isCorrect');

describe('isCorrect()', () => {

    it('[1] User input error information should return message', () => {
        let userInput = 'U123 2016-10-1 8:00~20:00 A';
        let actual = isCorrent.isCorrect(userInput);
        let result = "Error: the booking is invalid!";
        expect(actual).toBe(result);
    });
    it('[2] User input error information should return message', () => {
        let userInput = 'U123 2016-10-40 8:00~20:00 A';
        let actual = isCorrent.isCorrect(userInput);
        let result = "Error: the booking is invalid!";
        expect(actual).toBe(result);
    });
    it('[3] User input error information should return message', () => {
        let userInput = 'U1232016-10-18:00~20:00A';
        let actual = isCorrent.isCorrect(userInput);
        let result = "Error: the booking is invalid!";
        expect(actual).toBe(result);
    });
    it('[5] User input error information should return message', () => {
        let userInput = 'U123 2016-10-1 :009~2:000 A';
        let actual = isCorrent.isCorrect(userInput);
        let result = "Error: the booking is invalid!";
        expect(actual).toBe(result);
    });
    it('[6] User input error information should return message', () => {
        let userInput = 'U123 2016-13-1 9:00~20:00 E C';
        let actual = isCorrent.isCorrect(userInput);
        let result = "Error: the booking is invalid!";
        expect(actual).toBe(result);
    });
    it('The user enters the correct scheduled information and should return the scheduled data', () => {
        let userInput = 'U123 2016-10-01 9:00~20:00 A';
        let actual = isCorrent.isCorrect(userInput);
        let result = {
            data:{
                user: 'U123',
                date: '2016-10-01',
                time: '9:00~20:00',
                space: 'A'
            },
            method: 'booking'
        };
        expect(JSON.stringify(actual)).toBe(JSON.stringify(result));
    });
    it('The user entered the correct cancellation information and should return the scheduled data', () => {
        let userInput = 'U123 2016-10-01 9:00~20:00 A C';
        let actual = isCorrent.isCorrect(userInput);
        let result = {
            data:{
                user: 'U123',
                date: '2016-10-01',
                time: '9:00~20:00',
                space: 'A'
            },
            method: 'cancel'
        };
        expect(JSON.stringify(actual)).toBe(JSON.stringify(result));
    });
});